package com.wuchao.servlet;

import javax.servlet.*;
import javax.servlet.annotation.WebFilter;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;

/**
 * @author 吴超66
 * @version 1.0
 * @date 2022/4/20 14:14
 */
@WebFilter(filterName = "FilterInterceptor",urlPatterns = {"/demo5/t7.jsp","/eeee"})
public class FilterInterceptor implements Filter {
    public void destroy() {
    }

    public void doFilter( ServletRequest req, ServletResponse resp, FilterChain chain) throws ServletException, IOException {
        HttpSession session =((HttpServletRequest)req).getSession();
        String login =(String)session.getAttribute("login");
        if(login==null){
            //( (HttpServletResponse)resp).sendRedirect("demo5/t6.jsp?xx=g");
            req.getRequestDispatcher("t6.jsp?xx=g").forward(req,resp);
        }
        chain.doFilter(req, resp);
    }

    public void init(FilterConfig config) throws ServletException {

    }



}
